pg_connect problem

pg_connect problem

am 03.09.2003 19:36:14 von Edric Bulalacao

This is a multi-part message in MIME format.

------=_NextPart_000_001A_01C37207.331F6960
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by hosting.commandprompt.com id h83HcZK18299

I=92m a PHP/PostGRE newbie. I=92m getting this error:

Warning: pg_connect(): Unable to connect to PostgreSQL server: could not
connect to server: Connection refused Is the server running on host
localhost and accepting TCP/IP connections on port 5432? . in
/export/home/tsc/a/delete-action.phtml on line 156
Couldn't make a connection!

This is the code I=92m trying to run:
$connection =3D pg_connect("host=3Dlocalhost dbname=3Daddress user=3Daddr=
ess
password=3Daddress");

This is my pg_hba.conf
local all all password

This is the output of =93netstat =96an | grep 5432=94
unix 2 [ ACC ] STREAM LISTENING 27649 /tmp/.s.PGSQL.54=
32

I=92m able to do =93psql =96u address=94 and supply and username and pass=
word as any
Unix user defined in the system.


Can anyone tell me what I=92m doing wrong? Thanks.


------=_NextPart_000_001A_01C37207.331F6960
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hemas-microsoft-com:office:word" xmlns=3D"http://www.w3.org/TR/REC-html40">















face=3DArial> -family:
Arial'>I’m a PHP/PostGRE newbie.&nb=
sp;
I’m
getting this error:



face=3DArial> -family:
Arial'> 
<=
/span>



style=3D'font-size:12.0pt;font-family:Arial;color:black;font -weight:bold'>W=
arning
color=3Dblack face=3DArial>:
pg_connect(): Unable to connect to PostgreSQL server: could not connect to
server: Connection refused Is the server running on host localhost and
accepting TCP/IP connections on port 5432? . in ht:
bold'>/export/home/tsc/a/delete-action.phtml
on line style=3D'font-weight:bold'>156


Couldn't make a connection!<=
span
style=3D'font-family:Arial;color:black;mso-color-alt:windowt ext'> >



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>This is the code I’m trying to=
run:
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>$connection =3D
pg_connect("host=3Dlocalhost dbname=3Daddress user=3Daddress password=
=3Daddress");
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>This is my pg_hba.conf
=
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>local yes">  all yes">      all yes">           &nbs=
p;
password
mso-color-alt:windowtext'>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>This is the output of “netstat=
–an | grep
5432”
-color-alt:
windowtext'>



=
style=3D'font-size:12.0pt;color:black'>unix "> 
2      span>[
ACC ]    
STREAM    
LISTENING    
27649  /tmp/.s.PGSQL.5=
432
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>I’m able to do “psql =
211;u address” and
supply and username and password as any Unix user defined in the system. pan>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>Can anyone tell me what I’m do=
ing
wrong?  Thanks.
=
color=3Dblack> :p>



=
style=3D'font-size:12.0pt;color:black'>  ndif]>
color=3Dblack> :p>









------=_NextPart_000_001A_01C37207.331F6960--

Re: pg_connect problem

am 03.09.2003 20:00:21 von Joe Nilson Zegarra Galvez

in your pg_hba.conf must set a line with the follow:


local all all 127.0.0.1 255.255.255.255 trust
local all all IP.OF.YOUR.MACHINE YOUR.GATEWAY trust

and in your postgresql.conf must set the port =3D 5432 without the commen=
t
restart the postgresql and it must work

Regards


Nilson

> I=92m a PHP/PostGRE newbie. I=92m getting this error:
>
> Warning: pg_connect(): Unable to connect to PostgreSQL server: could no=
t
> connect to server: Connection refused Is the server running on host
> localhost and accepting TCP/IP connections on port 5432? . in
> /export/home/tsc/a/delete-action.phtml on line 156
> Couldn't make a connection!
>
> This is the code I=92m trying to run:
> $connection =3D pg_connect("host=3Dlocalhost dbname=3Daddress user=3Dad=
dress
> password=3Daddress");
>
> This is my pg_hba.conf
> local all all password
>
> This is the output of =93netstat =96an | grep 5432=94
> unix 2 [ ACC ] STREAM LISTENING 27649
> /tmp/.s.PGSQL.5432
>
> I=92m able to do =93psql =96u address=94 and supply and username and pa=
ssword as
> any
> Unix user defined in the system.
>
>
> Can anyone tell me what I=92m doing wrong? Thanks.
>
>


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: pg_connect problem

am 03.09.2003 20:00:40 von Robby Russell

Edric Bulalacao wrote:
> Thank you for the quick reply. Looks like all the lines in my
> postgresql.conf file are all commented out.
>
> I will uncomment the tcpip_socket and port lines lines to see if it works:
>
>

No problem. I've run into this on several occasions when I'm setting up
a new server and forget to make that one minor little change. It's a
good default security setting, however it adds one extra little step for
us. heh

-Robby

> # Connection Parameters
> #
> #tcpip_socket = true
> #ssl = false
>
> #max_connections = 32
> #superuser_reserved_connections = 2
>
> #port = 5432
> #hostname_lookup = false
> #show_source_port = false
>
>
>
> -----Original Message-----
> From: Robby Russell [mailto:rrussell@commandprompt.com]
> Sent: Wednesday, September 03, 2003 10:48 AM
> To: Edric Bulalacao
> Subject: Re: [PHP] pg_connect problem
>
> Edric Bulalacao wrote:
>
>>I'm a PHP/PostGRE newbie. I'm getting this error:
>>
>>Warning: pg_connect(): Unable to connect to PostgreSQL server: could not
>>connect to server: Connection refused Is the server running on host
>>localhost and accepting TCP/IP connections on port 5432? . in
>>/export/home/tsc/a/delete-action.phtml on line 156
>>Couldn't make a connection!
>
>
>>Can anyone tell me what I'm doing wrong? Thanks.
>
>
> Look at your postgres.conf file.
>
> Is TCP/IP on?
>
> tcpip_socket = true
>
>
>
> --
> Robby Russell, | Sr. Administrator / Lead Programmer
> Command Prompt, Inc. | http://www.commandprompt.com
> rrussell@commandprompt.com | Telephone: (503) 222.2783


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html